#include "tred.h"
#include <QDebug>
tred::tred()
{

}
int tred::generatorXY(int a)
{
    int coord;
    switch (a) {
    case 1:
    {
        coord=qrand()% 600;
        break;
    }
    case 2:
    {
        coord=qrand()% 550;
        break;
    }
    }
    return coord;
}

void tred::circlePaint()
{
    x = generatorXY(1);
    y = generatorXY(2);
    int fig=qrand()&2;
    if (fig<1)
    {
        QGraphicsEllipseItem *itm=new QGraphicsEllipseItem(x,y,50,50);
        itm->setData(0,'e');
        itm->setBrush(QBrush(QColor(255,0,255,200)));
        itm->setPen(QPen(Qt::white));
        emit retFig((QGraphicsItem*)itm);
    }
    else
    {
        QGraphicsRectItem *rect= new QGraphicsRectItem(x,y,50,50);
        rect->setBrush(QBrush(QColor(255,0,255,200)));
        rect->setPen(QPen(Qt::white));
        emit retFig((QGraphicsItem*)rect);
    }
}

void tred::run()
{
    qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
    circlePaint();

}
